home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / C / LIB / UNIXLIB37B / !UnixLib37 / src / unix / c / proc < prev    next >
Text File  |  1996-11-09  |  2KB  |  138 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /unixb/home/unixlib/source/unixlib37/src/unix/c/RCS/proc,v $
  4.  * $Date: 1996/10/30 22:04:51 $
  5.  * $Revision: 1.3 $
  6.  * $State: Rel $
  7.  * $Author: unixlib $
  8.  *
  9.  * $Log: proc,v $
  10.  * Revision 1.3  1996/10/30 22:04:51  unixlib
  11.  * Massive changes made by Nick Burret and Peter Burwood.
  12.  *
  13.  * Revision 1.2  1996/05/06 09:01:35  unixlib
  14.  * Updates to sources made by Nick Burrett, Peter Burwood and Simon Callan.
  15.  * Saved for 3.7a release.
  16.  *
  17.  * Revision 1.1  1996/04/19 21:35:27  simon
  18.  * Initial revision
  19.  *
  20.  ***************************************************************************/
  21.  
  22. static const char rcs_id[] = "$Id: proc,v 1.3 1996/10/30 22:04:51 unixlib Rel $";
  23.  
  24. #include <errno.h>
  25. #include <unistd.h>
  26. #include <sys/types.h>
  27. #include <sys/unix.h>
  28.  
  29. pid_t
  30. getpgrp (void)
  31. {
  32.   return (__u->pgrp);
  33. }
  34.  
  35. int
  36. setpgrp (pid_t pid, pid_t pgid)
  37. {
  38.   if (__u->pid == pid)
  39.     __u->pgrp = pgid;
  40.   return (0);
  41. }
  42.  
  43. int
  44. setpgid (pid_t pid, pid_t pgid)
  45. {
  46.   return setpgrp (pid, pgid);
  47. }
  48.  
  49. pid_t
  50. getpid (void)
  51. {
  52.   return (__u->pid);
  53. }
  54.  
  55. pid_t
  56. getppid (void)
  57. {
  58.   return (__u->ppid);
  59. }
  60.  
  61. uid_t
  62. getuid (void)
  63. {
  64.   return (__u->uid);
  65. }
  66.  
  67. int
  68. setuid (uid_t uid)
  69. {
  70.   if (uid == __u->uid)
  71.     return (0);
  72.   if (uid == __u->euid)
  73.     {
  74.       __u->uid = uid;
  75.       return (0);
  76.     }
  77.   return (-1);
  78. }
  79.  
  80. uid_t
  81. geteuid (void)
  82. {
  83.   return (__u->euid);
  84. }
  85.  
  86. int
  87. seteuid (uid_t uid)
  88. {
  89.   if (uid == __u->euid)
  90.     return (0);
  91.   if (uid == __u->uid)
  92.     {
  93.       __u->euid = uid;
  94.       return (0);
  95.     }
  96.   return (-1);
  97. }
  98.  
  99. gid_t
  100. getgid (void)
  101. {
  102.   return (__u->gid);
  103. }
  104.  
  105. /* Set the real and effective group ID of the process to gid.  */
  106.  
  107. int
  108. setgid (gid_t gid)
  109. {
  110.   if (gid == __u->gid)
  111.     return (0);
  112.   if (gid == __u->egid)
  113.     {
  114.       __u->gid = gid;
  115.       return (0);
  116.     }
  117.   return (-1);
  118. }
  119.  
  120. gid_t
  121. getegid (void)
  122. {
  123.   return (__u->egid);
  124. }
  125.  
  126. int
  127. setegid (gid_t gid)
  128. {
  129.   if (gid == __u->egid)
  130.     return (0);
  131.   if (gid == __u->gid)
  132.     {
  133.       __u->egid = gid;
  134.       return (0);
  135.     }
  136.   return (-1);
  137. }
  138.